package casts.step
{
   import flash.display.MovieClip;
   
   import jp.nium.display.getInstanceById;
   import jp.progression.casts.CastMovieClip;
   import jp.progression.commands.display.AddChild;
   import jp.progression.commands.display.RemoveChild;
   
   /**
    * @author cjboy1984
    * @usage
    */ 
   public class AbstractStep extends CastMovieClip
   {
      protected var loadingId:String = 'some loading';
      protected function get mcLoading():MovieClip { return MovieClip(getInstanceById(loadingId)); }
      
      protected var containerId:String = 'some container';
      protected function get container():MovieClip { return MovieClip(getInstanceById(containerId)); }

      public function AbstractStep(initObject:Object = null)
      {
         super(initObject);
      }
      
      // --------------------- LINE ---------------------
      
      // make step-container switch to the assigned step by giving step-id
      public function changeToStep(stepId:String):void
      {
         if (container)
         {
            container.changeToStep(stepId);
         }
      }
      
      // ################### protected ##################
      
      // add loading on step-container
      protected function addLoading():void
      {
         if (container && mcLoading && !container.contains(mcLoading)) 
         {
            new AddChild(this, mcLoading).execute();
         }
      }
      
      // remove loading from the loading's parent
      protected function removeLoading():void
      {
         if (mcLoading && mcLoading.parent)
         {
            new RemoveChild(mcLoading.parent, mcLoading).execute();
         }
      }
      
      // #################### private ###################
      
      // --------------------- LINE ---------------------
      
   }
   
}